﻿using System;
using System.Collections.Generic;
using System.Helpers;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataProcessModule.Protocol
{
    public class TimeReply : BaseInstruction
    {
        #region param

        private string TimeNow; 

        #endregion

        #region attributes

        public string AtTimeNow { get { return TimeNow; } }

        #endregion

        #region construction

        public TimeReply()
        {
            instHeadInfo.instID = 0x9118;
        }

        public TimeReply(byte[] buf)
        {

            int offset = 0;
            // 获取头信息
            GetHeadInfo(buf, ref offset);
            BodyStreamSplit(buf, ref offset);
        }

        #endregion

        #region function

        public void BodyStreamSplit(byte[] buf, ref int offset)
        {
            
        }

        public override byte[] GenerateInstructionStream()
        {           
            TimeNow = DateTime.Now.ToString("yyMMddHHmmss");

            InstBodyLength = 6;
            int offset = 0;
            instBodyData = new byte[InstBodyLength];

            BC.WriteBCD(this.TimeNow, 0, 12, instBodyData, ref offset);
            return base.GenerateInstructionStream();
        }

        #endregion
    }
}
